package edu.bbu.license.client.android.gui.files.adapter;

import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;

public class FilesActivityPageAdapter extends PagerAdapter {

	private List<View> pages = null;
	
	public FilesActivityPageAdapter(List<View> pages) {
		this.pages = pages;
	}
	
	@Override
	public int getCount() {
		return pages.size();
	}
	
	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		((ViewPager) container).addView(pages.get(position), 0);
		return pages.get(position);
	}

	@Override
	public boolean isViewFromObject(View view, Object object) {
		return view == object;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		((ViewPager) container).removeView((View) object);
		object = null;
	}
}
